<?php

namespace App\Repositories\Impl;

use App\Models\VolunteerForm;
use App\Repositories\Contracts\VolunteerFormRepository;

class VolunteerFormRepositoryImpl implements VolunteerFormRepository
{
    public function paginate($perPage, $filter)
    {
        $result = VolunteerForm::with('activity')->where($filter)->paginate($perPage);
        return $result;
    }

    public function find($id, $columns = ['*'])
    {
        return VolunteerForm::find($id, $columns);
    }

    public function findByFilter($filter, $columns = ['*'])
    {
        return VolunteerForm::where($filter)->first($columns);
    }

    public function store($data)
    {
        return VolunteerForm::create($data);
    }

    public function update($data, $id)
    {
        return VolunteerForm::whereId($id)->updateOrCreate($data);
    }

    public function updateByFilter($data, $where)
    {
        return VolunteerForm::where($where)->update($data);
    }

    public function delete($id)
    {
        return VolunteerForm::whereId($id)->delete();
    }
}
